<?php

namespace AdminBundle\Form;


use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use AdminBundle\Utility\Constant;

class AuthUserType extends AbstractType
{
    /**
     * {@inheritdoc}
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('username', TextType::class, [
            'label' => '用户名',
            'label_attr' => Constant::LABEL_ATTR_DEFAULT,
            'attr' => [
                'placeholder' => '请输入用户名',
                'class' => Constant::INPUT_ATTR_CLASS],
            'required' => true,
        ])->add('password', TextType::class, [
            'label' => '密码',
            'label_attr' => Constant::LABEL_ATTR_DEFAULT,
            'attr' => [
                'placeholder' => '请输入密码',
                'class' => Constant::INPUT_ATTR_CLASS],
            'required' => true,
        ])->add('email', EmailType::class, [
            'label' => '邮箱',
            'label_attr' => Constant::LABEL_ATTR_DEFAULT,
            'attr' => [
                'placeholder' => '请输入邮箱',
                'class' => Constant::INPUT_ATTR_CLASS],
            'required' => true,
        ])->add('note', TextareaType::class, [
            'label' => '注释',
            'label_attr' => Constant::LABEL_ATTR_DEFAULT,
            'attr' => [
                'placeholder' => '请输入注释',
                'class' => Constant::INPUT_ATTR_CLASS],
            'required' => false,
            'empty_data' => '',
        ])->add('isEnabled', CheckboxType::class, array(
                'label' => '启用',
                'label_attr' => Constant::LABEL_ATTR_DEFAULT,
                'attr' => [
                    'class' => 'ace ace-switch ace-switch-5',],
                'required' => false,
            )
        )->add('isSuperuser', CheckboxType::class, array(
                'label' => 'root',
                'label_attr' => Constant::LABEL_ATTR_DEFAULT,
                'attr' => [
                    'class' => 'ace ace-switch ace-switch-5',],
                'required' => false,
            )
        );

//        $builder->add('password')->add('lastLogin')->add('lastIp')->add('isSuperuser')->add('username')->add('note')->add('email')->add('salt')->add('isAccountNonExpired')->add('isCredentialsNonExpired')->add('isEnabled')->add('ctime')->add('createUser');
    }
    
    /**
     * {@inheritdoc}
     */
    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'AdminBundle\Entity\AuthUser'
        ));
    }

    /**
     * {@inheritdoc}
     */
    public function getBlockPrefix()
    {
        return 'adminbundle_authuser';
    }


}
